home *** CD-ROM | disk | FTP | other *** search
/ MacFormat 1995 June / MacFormat 25.iso / Shareware City / Developers / ICAppSourceKit1.0 / OSSubs.p < prev    next >
Encoding:
Text File  |  1994-11-06  |  1.1 KB  |  50 lines  |  [TEXT/PJMM]

  1. unit OSSubs;
  2.  
  3. interface
  4.  
  5.     function NumToolboxTraps: integer;
  6.     function GetTrapType (theTrap: Integer): TrapType;
  7.     function TrapAvailable (theTrap: integer): boolean;
  8.  
  9. implementation
  10.  
  11.     uses
  12.         Traps;
  13.  
  14.     function NumToolboxTraps: integer;
  15.     begin
  16.         if NGetTrapAddress(_InitGraf, ToolTrap) = NGetTrapAddress($AA6E, ToolTrap) then begin
  17.             NumToolboxTraps := $200
  18.         end
  19.         else begin
  20.             NumToolboxTraps := $400;
  21.         end; (* if *)
  22.     end; (* NumToolboxTraps *)
  23.  
  24.     function GetTrapType (theTrap: integer): TrapType;
  25.         const
  26.             TrapMask = $0800;
  27.     begin
  28.         if band(theTrap, TrapMask) > 0 then begin
  29.             GetTrapType := ToolTrap
  30.         end
  31.         else begin
  32.             GetTrapType := OSTrap;
  33.         end; (* if *)
  34.     end; (* GetTrapType *)
  35.  
  36.     function TrapAvailable (theTrap: integer): boolean;
  37.         var
  38.             tType: TrapType;
  39.     begin
  40.         tType := GetTrapType(theTrap);
  41.         if tType = ToolTrap then begin
  42.             theTrap := band(theTrap, $07FF);
  43.             if theTrap >= NumToolboxTraps then begin
  44.                 theTrap := _Unimplemented;
  45.             end; (* if *)
  46.         end; (* if *)
  47.         TrapAvailable := NGetTrapAddress(theTrap, tType) <> NGetTrapAddress(_Unimplemented, ToolTrap);
  48.     end; (* TrapAvailable *)
  49.  
  50. end. (* OSSubs *)